package com.hiss.basic.system.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.hiss.basic.client.system.ISysLoginLogService;
import com.hiss.basic.client.system.ISysOperateLogService;
import com.hiss.basic.model.system.request.SysLoginLogQueryRequest;
import com.hiss.basic.model.system.request.SysOperateLogQueryRequest;
import com.hiss.basic.model.system.response.SysLoginLogQueryResponse;
import com.hiss.basic.model.system.response.SysOperateLogQueryResponse;
import com.hiss.basic.starter.core.model.R;
import com.mybatisflex.core.paginate.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sys/log")
public class SysLogController {

    @Resource
    private ISysLoginLogService sysLoginLogService;

    @Resource
    private ISysOperateLogService sysOperateLogService;

    @SaCheckPermission("sys:login-log:list")
    @RequestMapping(value = "/login/list/page", method = RequestMethod.GET)
    public R<Page<SysLoginLogQueryResponse>> loginListPage(SysLoginLogQueryRequest request) {
        Page<SysLoginLogQueryResponse> logListPage = sysLoginLogService.findPageList(request);
        return R.success(logListPage);
    }

    @SaCheckPermission("sys:operate-log:list")
    @RequestMapping(value = "/operate/list/page", method = RequestMethod.GET)
    public R<Page<SysOperateLogQueryResponse>> operateListPage(SysOperateLogQueryRequest request) {
        Page<SysOperateLogQueryResponse> logListPage = sysOperateLogService.findPageList(request);
        return R.success(logListPage);
    }
}
